package com.xyzwps.server.paimon.ui.mvc

import com.xyzwps.server.paimon.app.ContextUser
import com.xyzwps.server.paimon.app.dto.Me
import com.xyzwps.server.paimon.app.dto.MeUpdateInput
import com.xyzwps.server.paimon.app.MeAppService
import com.xyzwps.server.paimon.spring.AuthUser
import com.xyzwps.server.paimon.ui.HttpResponse
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.web.bind.annotation.*

@Tag(name = "Me")
@RestController
@RequestMapping(Apis.BASE + "/me")
class MeController(private val meAppService: MeAppService) {

    @GetMapping
    fun me(@AuthUser user: ContextUser): HttpResponse<Me> {
        return HttpResponse(meAppService.me(user))
    }

    @PutMapping
    fun update(
        @AuthUser user: ContextUser,
        @RequestBody input: MeUpdateInput
    ): HttpResponse<Me> {
        return HttpResponse(meAppService.meUpdate(user, input))
    }
}
